package com.wanxi.servlet;

import com.wanxi.model.BrandModel;
import com.wanxi.service.BrandService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/show")
public class ShowServlet extends HttpServlet {
    List<BrandModel> brandModelList = new ArrayList<>();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

//        for (int i = 0; i < 3; i++) {
//            BrandModel model = new BrandModel();
//            model.setId(1);
//            model.setName("三只松鼠");
//            model.setEnterprise("三只松鼠");
//            model.setSort(100);
//            model.setIntroduction("三只松鼠");
//            model.setStatus(1);
//            brandModelList.add(model);
//        }
        BrandService brandService=new BrandService();
        brandModelList=brandService.findAll();
        req.setAttribute("brandModelList", brandModelList);
        req.getRequestDispatcher("/show.jsp").forward(req, resp);
    }
}
